import time

from selenium.webdriver.chrome import webdriver
from selenium.webdriver.common.by import By

from pages.basePage import BasePage


class Address(BasePage):
    userName=(By.NAME,"username")
    userPassword=(By.NAME,"password")
    userSumit=(By.NAME,"submit")
    provinces=(By.CSS_SELECTOR,"#selProvinces_1")

    deleAddre = (By.XPATH, "/html/body/div[6]/div[2]/div/div/div/form[2]/table/tbody/tr[6]/td[2]/input[2]")

    electProvinces=(By.XPATH,"//*[@id='selProvinces_1']//*[@value='2']")
    citys=(By.ID,"selCities_1")
    selectcitys=(By.XPATH,"//*[@id='selCities_1']//option[2]")
    districts=(By.XPATH,'//*[@id="selDistricts_1"]')
    selectDistrict=(By.XPATH,'//*[@id="selDistricts_1"]//option[6]')
    consignee=(By.XPATH,'//*[@id="consignee_1"]')
    detailAddress=(By.XPATH,'//*[@id="address_1"]')
    tel=(By.XPATH,'//*[@id="tel_1"]')
    sumitAddre=(By.XPATH,"//*[@name='submit' and @class='bnt_blue_2']")


    def address(self,a,b,c,d,e):
        #a="张张",b="beijing小胡同",c="163486735",d="张张",e="123456"
        # self.login = webdriver.WebDriver()
        self.login.get("http://192.168.40.130/user.php?act=address_list")

        self.login.implicitly_wait(10)

        self.login.find_element(*self.userName).send_keys(d)
        self.login.find_element(*self.userPassword).send_keys(e)
        self.login.find_element(*self.userSumit).click()
        self.login.find_element(*self.provinces).click()
        self.login.find_element(*self.electProvinces).click()
        self.login.find_element(*self.citys).click()
        self.login.find_element(*self.selectcitys).click()
        self.login.find_element(*self.districts).click()
        self.login.find_element(*self.selectDistrict).click()
        self.login.find_element(*self.consignee).send_keys(a)
        self.login.find_element(*self.detailAddress).send_keys(b)
        self.login.find_element(*self.tel).send_keys(c)
        self.login.find_element(*self.sumitAddre).click()
        self.login.find_element(*self.deleAddre).click()


if __name__ == '__main__':
    addre=Address()
    addre.address("张张","beijing小胡同","163486735","张张","123456")

